#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <map>
#include <stdlib.h>
#include <lineages.h>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <shared.h>

using namespace std;

int main(int argc, char *argv[])
{
    string realLineagesFile = argv[1];
    int simStart = atoi(argv[2]);
    int simLoop = atoi(argv[3]);
    int randSeed = atoi(argv[4]);
    string simFile = argv[5];
    srand(randSeed);

    vector<int> termTypes;
    vector<string> termLineages;
    vector<vector<string> > lineagesPool;
    vector<vector<int> > typesPool;

    loadRealLineages(realLineagesFile,termTypes,termLineages);
    Lineages realLin(termTypes,termLineages);

    realLin.getDepthStat();

    cout << "Lineage Name\tDifferentiation Program Depth\tProliferation Program Depth" << endl;
    cout << realLineagesFile << "\t";
    for(unsigned int i=0;i<realLin.diffDepth.size();i++) cout << realLin.diffDepth[i] << ";";
    cout << "\t";
    for(unsigned int i=0;i<realLin.prolifDepth.size();i++) cout << realLin.prolifDepth[i] << ";";
    cout << endl;

    for(int i=simStart; i<simStart+simLoop; i++)
    {
        lineagesPool.clear();
        typesPool.clear();
        loadLineageCollection(simFile,i,1,typesPool,lineagesPool);

        termTypes = typesPool[0];
        termLineages = lineagesPool[0];

        Lineages simLin(termTypes,termLineages);
        double simComplexity;
        simLin.getDepthStat();
        simComplexity = simLin.complexity();

        cout << i << "\t";
        for(unsigned int j=0;j<simLin.diffDepth.size();j++) cout << simLin.diffDepth[j] << ";";
        cout << "\t";
        for(unsigned int j=0;j<simLin.prolifDepth.size();j++) cout << simLin.prolifDepth[j] << ";";
        cout << endl;
    }

    return 0;
}
